#!/bin/bash

# 任务完成率影响因素分析运行脚本

# 显示彩色输出
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color

echo -e "${YELLOW}=======================================${NC}"
echo -e "${YELLOW}  任务完成率影响因素分析  ${NC}"
echo -e "${YELLOW}=======================================${NC}"

# 检查Python是否安装
if ! command -v python3 &> /dev/null; then
    echo -e "${RED}错误: 找不到Python3。请安装Python3后再运行此脚本。${NC}"
    exit 1
fi

# 检查是否在正确的目录中
if [ ! -f "main.py" ]; then
    echo -e "${RED}错误: 找不到main.py文件。请确保您在tf-model-development目录中运行此脚本。${NC}"
    exit 1
fi

# 检查数据文件是否存在
if [ ! -f "data/completion_data.csv" ]; then
    echo -e "${RED}错误: 找不到数据文件。请确保data/completion_data.csv文件存在。${NC}"
    exit 1
fi

# 检查依赖项
echo -e "${GREEN}检查依赖项...${NC}"
python3 -c "
try:
    import tensorflow as tf
    import pandas as pd
    import numpy as np
    import matplotlib.pyplot as plt
    import seaborn as sns
    from sklearn.model_selection import train_test_split
    print('所有依赖项已安装')
except ImportError as e:
    print(f'缺少依赖项: {e}')
    print('请运行: pip install tensorflow pandas numpy matplotlib seaborn scikit-learn')
    exit(1)
"

if [ $? -ne 0 ]; then
    echo -e "${RED}请安装所需的依赖项后再运行此脚本。${NC}"
    exit 1
fi

# 创建输出目录
mkdir -p output

# 运行主程序
echo -e "${GREEN}运行分析程序...${NC}"
python3 main.py

echo -e "${GREEN}分析完成！${NC}"
echo -e "${GREEN}结果已保存到output目录。${NC}"
echo -e "${YELLOW}=======================================${NC}"